home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 32
/
Amiga Format AFCD32 (Nov 1998, Issue 117).iso
/
-in_the_mag-
/
under_the_bonnet
/
cwfloppy-0.1.4
/
cwfloppy.h
< prev
next >
Wrap
C/C++ Source or Header
|
1998-08-22
|
4KB
|
159 lines
#ifndef _CWFLOPPY_H
#define _CWFLOPPY_H
#include <linux/ioctl.h>
/* Change this if you want */
#define CWFLOPPY_MAJOR 120
/*
* Disk geometry description
*/
struct cwfloppy_format {
const char name[32];
int blksize; /* block size in bytes */
int numblocks; /* number of blocks on the disk */
unsigned char max_secs_per_track; /* e.g. 21 for 1541 disks */
unsigned char heads;
unsigned char cylinders;
unsigned char readonly;
int clock; /* 0 = high, 1 = low */
int readtime; /* slightly more than one rotation of the disk */
struct cw_codec *codec;
};
extern const struct cwfloppy_format cw_formats[];
#define CWGETPRM _IOR(2, 0x04, struct cwfloppy_format)
#define CWFMTBEG _IO(2, 0x47)
#define CWFMTTRK _IO(2, 0x48)
#define CWFMTEND _IO(2, 0x49)
#define FD_FILL_BYTE 0xF6 /* format fill byte. */
#ifdef __KERNEL__
#include <linux/version.h>
#if LINUX_VERSION_CODE < 0x020100
#include <linux/stddef.h>
#include <linux/timer.h>
#include <linux/kdev_t.h>
#endif
/*
* Some macros for the kernel module
*/
#define MAJOR_NR CWFLOPPY_MAJOR
#define DEVICE_NAME "cwfloppy"
#define DEVICE_REQUEST do_cw_request
#define DEVICE_NR(device) (MINOR(device))
#define DEVICE_ON(device)
#define DEVICE_OFF(device)
#define DEVICE_NO_RANDOM
#define TIMEOUT_VALUE (6 * HZ)
/*
* Low-level routines -- sorry, only the headers :-(
*/
typedef struct catweasel_drive {
struct catweasel_contr *contr; /* The controller this drive belongs to */
int number; /* Drive number: 0 or 1 */
int type; /* 0 = not present, 1 = 3.5" */
int track; /* current r/w head position (0..79) */
int diskindrive; /* 0 = no disk, 1 = disk in drive */
int wprot; /* 0 = not, 1 = write protected */
} catweasel_drive;
typedef struct catweasel_contr {
int iobase; /* 0 = not present */
void (*msdelay)(int ms); /* microseconds delay routine */
catweasel_drive drives[2]; /* max. two drives on each controller */
int private[4]; /* private data */
} catweasel_contr;
/* Initialize a Catweasel controller; c->iobase and c->msdelay must have
been initialized -- msdelay might be used */
void catweasel_init_controller(catweasel_contr *c);
/* Reset the controller */
void catweasel_free_controller(catweasel_contr *c);
/* Set current drive select mask */
void catweasel_select(catweasel_contr *c, int dr0, int dr1);
/* Start/stop the drive's motor */
void catweasel_set_motor(catweasel_drive *d, int on);
/* Move the r/w head -- msdelay might be used */
void catweasel_seek(catweasel_drive *d, int track);
/* Check for a disk change and update d->diskindrive
-- msdelay might be used. Returns 1 == disk has been changed */
int catweasel_disk_changed(catweasel_drive *d);
/* Check if disk in selected drive is write protected. */
int catweasel_write_protected(catweasel_drive *d);
/* Read data -- msdelay will be used */
int catweasel_read(catweasel_drive *d, int side, int clock, int time);
/* Write data -- msdelay will be used */
int catweasel_write(catweasel_drive *d, int side, int clock, int time);
/*
* The structures used by cwfloppy.c
*/
struct cw_drive_struct {
struct cw_controller_struct *c;
catweasel_drive *d;
int format; /* 0..30 */
unsigned char *trackbuffer;
int bufferedtrack;
int defectivetrack;
struct timer_list motor_off_timer;
int motor;
int in_use;
kdev_t last_devt;
};
struct cw_controller_struct {
catweasel_contr c;
struct cw_drive_struct drives[2];
};
extern void cw_codec_error(const char *fmt, ...);
/*
* And some codec interface definitions
*/
struct cw_codec {
int (*decode)(struct cw_drive_struct *drive,
int side,
int try);
void (*encode)(struct cw_drive_struct *drive,
int side);
};
extern struct cw_codec cw_codec_msdos, cw_codec_amiga;
extern void codec_msdos_init();
#endif /* __KERNEL__ */
#endif /* _CWFLOPPY_H */